﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Collections.Generic;

namespace ExcelMapper.Test
{
    [TestClass]
    public class ExcelQueryTest
    {
        ExcelDocument document { get; set; }
        
        public ExcelQueryTest()
        {
            var path = Directory.GetCurrentDirectory();
            string filePath = path + @"\FakeData\ExcelFake.xlsx";
            document = new ExcelDocument(filePath);
            document.Name = "testDocument";
            document.PrimaryKeyColumnName = "Cabecera1";
            document.Load();
        }

        [TestMethod]
        public void ExcelQueryBasicTest()
        {
            ExcelQuery query = new ExcelQuery(document);
            var result = query.BasicQuery("testDocument", "Cabecera 2", "6");
            var expected = "DSA";
            Assert.AreEqual(expected,result);

        }


        [TestMethod]
        public void ExcelQueryBasicTTest()
        {
            ExcelQuery query = new ExcelQuery(document);
            var result = query.BasicQuery<double>("testDocument", "Cabecera 3", "3");
            var expected = 43221;
            Assert.AreEqual(expected, result);

        }

        [TestMethod]
        public void ExcelQueryListTest()
        {
            ExcelQuery query = new ExcelQuery(document);
            var result = query.BasicQueryList<double>("testDocument", "Cabecera 3", "7");
            var expected = 3;
            Assert.AreEqual(expected, result.Count);

        }

    }
}
